﻿using NewsSystem.Contracts;
using NewsSystem.Models;
using System.Data.Entity;
using System.Linq;

namespace NewsSystem.Repositories
{
    public class UsersRepository : BaseRepository<User>, IUserRepository
    {
        public UsersRepository(DbContext dbContext)
            :base(dbContext)
        {
        }

        public User GetBySessionId(string sessionId)
        {
            var user = this.DbSet.Where(u => u.SessionId == sessionId).FirstOrDefault();

            return user;
        }

        public User GetByEmailAndPassword(string email, string password)
        {
            var user = this.DbSet
                .Where(u => u.Email == email && u.PasswordHashed == password)
                .FirstOrDefault();

            return user;
        }
    }
}
